package cn.edu.tju.elm.mapper;

import cn.edu.tju.elm.dto.FoodResponseDTO;
import cn.edu.tju.elm.dto.FoodUpdateDTO;
import cn.edu.tju.elm.model.Food;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

/**
 * ClassName: FoodMapper
 * Package: cn.edu.tju.elm.mapper
 * Description: 商品实体和DTO转换器
 *
 * @Author Niu Wenhang
 * @Create 2025/9/20 12:00
 * @Version 1.0
 */
@Mapper(componentModel = "spring")
public interface FoodMapper {

    @Mapping(source = "business.id", target = "businessId")
    @Mapping(source = "business.businessName", target = "businessName")
    FoodResponseDTO foodToResponseDTO(Food food);

    List<FoodResponseDTO> foodsToResponseDTOs(List<Food> foods);

    @Mapping(target = "business.id", source = "businessId")
    Food updateDtoToFood(FoodUpdateDTO dto);
}
